package faa;
import java.util.*;

public final class UserDatabase {
	//Data
	private static Map<String,UserSchema> schemas = new HashMap<String,UserSchema>();
	static {
		schemas.put("bsmith",new UserSchema("bsmith","password","ATC"));
		schemas.put("agoldman",new UserSchema("agoldman","password","MANAGER"));
	}
	
	/**
	 * private constructor to stop people instantiating it.
	 */
	private UserDatabase() {

	}

	public static UserSchemaLookUp LookUpUser(String username, String password) {
		if(schemas.containsKey(username)){
			UserSchema us = schemas.get(username);
			
				if(us.getPassword().equals(password)){
					return new UserSchemaLookUp(us,LookUpSucess.CORRECT);
				} else {
					return new UserSchemaLookUp(LookUpSucess.BAD_PASSWORD);
				}
		}else {
			return new UserSchemaLookUp(LookUpSucess.BAD_USERNAME);
		}
	}

}